<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  
  


  <head>
    <title>
      Default.aspx.cs in trunk/sky/AngleInGSky
     – GoogleSky
    </title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="search" href="/trac/GoogleSky/search" />
        <link rel="help" href="/trac/GoogleSky/wiki/TracGuide" />
        <link rel="alternate" href="/trac/GoogleSky/browser/trunk/sky/AngleInGSky/Default.aspx.cs?format=txt" type="text/plain" title="Plain Text" /><link rel="alternate" href="/trac/GoogleSky/export/303/trunk/sky/AngleInGSky/Default.aspx.cs" type="text/x-csharp; charset=iso-8859-15" title="Original Format" />
        <link rel="start" href="/trac/GoogleSky/wiki" />
        <link rel="stylesheet" href="/trac/GoogleSky/chrome/common/css/trac.css" type="text/css" /><link rel="stylesheet" href="/trac/GoogleSky/chrome/common/css/code.css" type="text/css" /><link rel="stylesheet" href="/trac/GoogleSky/chrome/common/css/browser.css" type="text/css" />
        <link rel="prev" href="/trac/GoogleSky/browser/trunk/sky/AngleInGSky/Default.aspx.cs?rev=96" title="Revision 96" />
        <link rel="shortcut icon" href="/trac/GoogleSky/chrome/common/trac.ico" type="image/x-icon" />
        <link rel="icon" href="/trac/GoogleSky/chrome/common/trac.ico" type="image/x-icon" />
      <link type="application/opensearchdescription+xml" rel="search" href="/trac/GoogleSky/search/opensearch" title="Search GoogleSky" />
    <script type="text/javascript" src="/trac/GoogleSky/chrome/common/js/jquery.js"></script><script type="text/javascript" src="/trac/GoogleSky/chrome/common/js/babel.js"></script><script type="text/javascript" src="/trac/GoogleSky/chrome/common/js/trac.js"></script><script type="text/javascript" src="/trac/GoogleSky/chrome/common/js/search.js"></script>
    <!--[if lt IE 7]>
    <script type="text/javascript" src="/trac/GoogleSky/chrome/common/js/ie_pre7_hacks.js"></script>
    <![endif]-->
    <script type="text/javascript" src="/trac/GoogleSky/chrome/common/js/folding.js"></script><script type="text/javascript">
      jQuery(document).ready(function($) {
        $(".trac-toggledeleted").show().click(function() {
                  $(this).siblings().find(".trac-deleted").toggle();
                  return false;
        }).click();
        $("#jumploc input").hide();
        $("#jumploc select").change(function () {
          this.parentNode.parentNode.submit();
        });
          $('#preview table.code').enableCollapsibleColumns($('#preview table.code thead th.content'));
      });
    </script>
  </head>
  <body>
    <div id="banner">
      <div id="header">
        <a id="logo" href="https://www.stsci.edu/trac/GoogleSky"><img src="/trac/GoogleSky/chrome/site/GoogleSky.png" alt="" height="110" width="187" /></a>
      </div>
      <form id="search" action="/trac/GoogleSky/search" method="get">
        <div>
          <label for="proj-search">Search:</label>
          <input type="text" id="proj-search" name="q" size="18" value="" />
          <input type="submit" value="Search" />
        </div>
      </form>
      <div id="metanav" class="nav">
    <ul>
      <li class="first"><a href="/trac/GoogleSky/login">Login</a></li><li><a href="/trac/GoogleSky/wiki/TracGuide">Help/Guide</a></li><li><a href="/trac/GoogleSky/about">About Trac</a></li><li class="last"><a href="/trac/GoogleSky/prefs">Preferences</a></li>
    </ul>
  </div>
    </div>
    <div id="mainnav" class="nav">
    <ul>
      <li class="first"><a href="/trac/GoogleSky/wiki">Wiki</a></li><li><a href="/trac/GoogleSky/timeline">Timeline</a></li><li><a href="/trac/GoogleSky/roadmap">Roadmap</a></li><li class="active"><a href="/trac/GoogleSky/browser">Browse Source</a></li><li><a href="/trac/GoogleSky/report">View Tickets</a></li><li class="last"><a href="/trac/GoogleSky/search">Search</a></li>
    </ul>
  </div>
    <div id="main">
      <div id="ctxtnav" class="nav">
        <h2>Context Navigation</h2>
          <ul>
              <li class="first"><span>&larr; <a class="prev" href="/trac/GoogleSky/browser/trunk/sky/AngleInGSky/Default.aspx.cs?rev=96" title="Revision 96">Previous Revision</a></span></li><li><span class="missing">Next Revision &rarr;</span></li><li><a href="/trac/GoogleSky/browser/trunk/sky/AngleInGSky/Default.aspx.cs?annotate=blame&amp;rev=166" title="Annotate each line with the last changed revision (this can be time consuming...)">Annotate</a></li><li class="last"><a href="/trac/GoogleSky/log/trunk/sky/AngleInGSky/Default.aspx.cs">Revision Log</a></li>
          </ul>
        <hr />
      </div>
    <div id="content" class="browser">
          <h1>
<a class="pathentry first" href="/trac/GoogleSky/browser?order=name" title="Go to repository root">source:</a>
<a class="pathentry" href="/trac/GoogleSky/browser/trunk?order=name" title="View trunk">trunk</a><span class="pathentry sep">/</span><a class="pathentry" href="/trac/GoogleSky/browser/trunk/sky?order=name" title="View sky">sky</a><span class="pathentry sep">/</span><a class="pathentry" href="/trac/GoogleSky/browser/trunk/sky/AngleInGSky?order=name" title="View AngleInGSky">AngleInGSky</a><span class="pathentry sep">/</span><a class="pathentry" href="/trac/GoogleSky/browser/trunk/sky/AngleInGSky/Default.aspx.cs?order=name" title="View Default.aspx.cs">Default.aspx.cs</a>
<span class="pathentry sep">@</span>
  <a class="pathentry" href="/trac/GoogleSky/changeset/166" title="View changeset 166">166</a>
<br style="clear: both" />
</h1>
        <div id="jumprev">
          <form action="" method="get">
            <div>
              <label for="rev">
                View revision:</label>
              <input type="text" id="rev" name="rev" size="6" />
            </div>
          </form>
        </div>
        <div id="jumploc">
          <form action="" method="get">
            <div class="buttons">
              <label for="preselected">Visit:</label>
              <select id="preselected" name="preselected">
                <option selected="selected"></option>
                <optgroup label="branches">
                  <option value="/trac/GoogleSky/browser/trunk">trunk</option>
                </optgroup>
              </select>
              <input type="submit" value="Go!" title="Jump to the chosen preselected path" />
            </div>
          </form>
        </div>
      <table id="info" summary="Revision info">
        <tr>
          <th scope="col">Revision <a href="/trac/GoogleSky/changeset/166">166</a>,
            <span title="15187 bytes">14.8 KB</span>
            checked in by aconti, <a class="timeline" href="/trac/GoogleSky/timeline?from=2008-12-27T18%3A04%3A13-05%3A00&amp;precision=second" title="2008-12-27T18:04:13-05:00 in Timeline">2 years</a> ago
            (<a href="/trac/GoogleSky/changeset/166/trunk/sky/AngleInGSky/Default.aspx.cs">diff</a>)</th>
        </tr>
        <tr>
          <td class="message searchable">
              <p>
checking in new solution with BCG<br />
</p>
          </td>
        </tr>
      </table>
      <div id="preview" class="searchable">
        
  <table class="code"><thead><tr><th class="lineno" title="Line numbers">Line</th><th class="content"> </th></tr></thead><tbody><tr><th id="L1"><a href="#L1">1</a></th><td>/* Copyright 2007 Alberto Conti */</td></tr><tr><th id="L2"><a href="#L2">2</a></th><td>using System;</td></tr><tr><th id="L3"><a href="#L3">3</a></th><td>using System.Data;</td></tr><tr><th id="L4"><a href="#L4">4</a></th><td>using System.Configuration;</td></tr><tr><th id="L5"><a href="#L5">5</a></th><td>using System.IO;</td></tr><tr><th id="L6"><a href="#L6">6</a></th><td>using System.Text;</td></tr><tr><th id="L7"><a href="#L7">7</a></th><td>using System.Web;</td></tr><tr><th id="L8"><a href="#L8">8</a></th><td>using System.Web.Security;</td></tr><tr><th id="L9"><a href="#L9">9</a></th><td>using System.Web.UI;</td></tr><tr><th id="L10"><a href="#L10">10</a></th><td>using System.Web.UI.WebControls;</td></tr><tr><th id="L11"><a href="#L11">11</a></th><td>using System.Web.UI.WebControls.WebParts;</td></tr><tr><th id="L12"><a href="#L12">12</a></th><td>using System.Web.UI.HtmlControls;</td></tr><tr><th id="L13"><a href="#L13">13</a></th><td></td></tr><tr><th id="L14"><a href="#L14">14</a></th><td>using System.Drawing;</td></tr><tr><th id="L15"><a href="#L15">15</a></th><td>using System.Drawing.Imaging;</td></tr><tr><th id="L16"><a href="#L16">16</a></th><td>using System.Drawing.Drawing2D;</td></tr><tr><th id="L17"><a href="#L17">17</a></th><td>using System.Drawing.Text;</td></tr><tr><th id="L18"><a href="#L18">18</a></th><td></td></tr><tr><th id="L19"><a href="#L19">19</a></th><td>using kml22.kml;</td></tr><tr><th id="L20"><a href="#L20">20</a></th><td>using kml22.xs;</td></tr><tr><th id="L21"><a href="#L21">21</a></th><td></td></tr><tr><th id="L22"><a href="#L22">22</a></th><td>public partial class _Default : System.Web.UI.Page </td></tr><tr><th id="L23"><a href="#L23">23</a></th><td>{</td></tr><tr><th id="L24"><a href="#L24">24</a></th><td>    string currentServer = null;</td></tr><tr><th id="L25"><a href="#L25">25</a></th><td>    string currentPath = null;</td></tr><tr><th id="L26"><a href="#L26">26</a></th><td>    public enum sType {production, testing, development}</td></tr><tr><th id="L27"><a href="#L27">27</a></th><td>    public enum angleType { BBOX, Range }</td></tr><tr><th id="L28"><a href="#L28">28</a></th><td>    string scale = null;</td></tr><tr><th id="L29"><a href="#L29">29</a></th><td></td></tr><tr><th id="L30"><a href="#L30">30</a></th><td>    protected void Page_Load(object sender, EventArgs e)</td></tr><tr><th id="L31"><a href="#L31">31</a></th><td>    {</td></tr><tr><th id="L32"><a href="#L32">32</a></th><td></td></tr><tr><th id="L33"><a href="#L33">33</a></th><td>        double west=0, south=0, east=0, north=0;</td></tr><tr><th id="L34"><a href="#L34">34</a></th><td>        double lookatLon = 0, lookatLat = 0, lookatRange = 0, lookatTilt = 0, lookatHeading = 0;</td></tr><tr><th id="L35"><a href="#L35">35</a></th><td>        double horizFov = 0, vertFov = 0, horizPixels = 0, vertPixels = 0, terrainEnabled = 0;</td></tr><tr><th id="L36"><a href="#L36">36</a></th><td></td></tr><tr><th id="L37"><a href="#L37">37</a></th><td>        #region BBOX</td></tr><tr><th id="L38"><a href="#L38">38</a></th><td>        try</td></tr><tr><th id="L39"><a href="#L39">39</a></th><td>        {</td></tr><tr><th id="L40"><a href="#L40">40</a></th><td>            string BBOX = Request.QueryString["BBOX"];</td></tr><tr><th id="L41"><a href="#L41">41</a></th><td></td></tr><tr><th id="L42"><a href="#L42">42</a></th><td>            west  = Convert.ToDouble(BBOX.Split(',')[0]);</td></tr><tr><th id="L43"><a href="#L43">43</a></th><td>            south = Convert.ToDouble(BBOX.Split(',')[1]);</td></tr><tr><th id="L44"><a href="#L44">44</a></th><td>            east  = Convert.ToDouble(BBOX.Split(',')[2]);</td></tr><tr><th id="L45"><a href="#L45">45</a></th><td>            north = Convert.ToDouble(BBOX.Split(',')[3]);</td></tr><tr><th id="L46"><a href="#L46">46</a></th><td>        }</td></tr><tr><th id="L47"><a href="#L47">47</a></th><td>        catch (Exception ex) { }</td></tr><tr><th id="L48"><a href="#L48">48</a></th><td>        #endregion</td></tr><tr><th id="L49"><a href="#L49">49</a></th><td></td></tr><tr><th id="L50"><a href="#L50">50</a></th><td>        #region CAMERA</td></tr><tr><th id="L51"><a href="#L51">51</a></th><td>        try </td></tr><tr><th id="L52"><a href="#L52">52</a></th><td>        {</td></tr><tr><th id="L53"><a href="#L53">53</a></th><td>            string CAMERA = Request.QueryString["CAMERA"];</td></tr><tr><th id="L54"><a href="#L54">54</a></th><td></td></tr><tr><th id="L55"><a href="#L55">55</a></th><td>            lookatLon     = Convert.ToDouble(CAMERA.Split(',')[0]);</td></tr><tr><th id="L56"><a href="#L56">56</a></th><td>            lookatLat     = Convert.ToDouble(CAMERA.Split(',')[1]);</td></tr><tr><th id="L57"><a href="#L57">57</a></th><td>            lookatRange   = Convert.ToDouble(CAMERA.Split(',')[2]);</td></tr><tr><th id="L58"><a href="#L58">58</a></th><td>            lookatTilt    = Convert.ToDouble(CAMERA.Split(',')[3]);</td></tr><tr><th id="L59"><a href="#L59">59</a></th><td>            lookatHeading = Convert.ToDouble(CAMERA.Split(',')[4]);</td></tr><tr><th id="L60"><a href="#L60">60</a></th><td>        }</td></tr><tr><th id="L61"><a href="#L61">61</a></th><td>        catch (Exception ex1) { }</td></tr><tr><th id="L62"><a href="#L62">62</a></th><td>        #endregion</td></tr><tr><th id="L63"><a href="#L63">63</a></th><td></td></tr><tr><th id="L64"><a href="#L64">64</a></th><td>        #region VIEW</td></tr><tr><th id="L65"><a href="#L65">65</a></th><td>        try</td></tr><tr><th id="L66"><a href="#L66">66</a></th><td>        {</td></tr><tr><th id="L67"><a href="#L67">67</a></th><td>            string VIEW = Request.QueryString["VIEW"];</td></tr><tr><th id="L68"><a href="#L68">68</a></th><td>            </td></tr><tr><th id="L69"><a href="#L69">69</a></th><td>            horizFov       = Convert.ToDouble(VIEW.Split(',')[0]);</td></tr><tr><th id="L70"><a href="#L70">70</a></th><td>            vertFov        = Convert.ToDouble(VIEW.Split(',')[1]);</td></tr><tr><th id="L71"><a href="#L71">71</a></th><td>            horizPixels    = Convert.ToDouble(VIEW.Split(',')[2]);</td></tr><tr><th id="L72"><a href="#L72">72</a></th><td>            vertPixels     = Convert.ToDouble(VIEW.Split(',')[3]);</td></tr><tr><th id="L73"><a href="#L73">73</a></th><td>            terrainEnabled = Convert.ToDouble(VIEW.Split(',')[4]);</td></tr><tr><th id="L74"><a href="#L74">74</a></th><td>        }</td></tr><tr><th id="L75"><a href="#L75">75</a></th><td>        catch (Exception ex2) { }</td></tr><tr><th id="L76"><a href="#L76">76</a></th><td>        #endregion</td></tr><tr><th id="L77"><a href="#L77">77</a></th><td></td></tr><tr><th id="L78"><a href="#L78">78</a></th><td>        #region ServerType s </td></tr><tr><th id="L79"><a href="#L79">79</a></th><td>        try</td></tr><tr><th id="L80"><a href="#L80">80</a></th><td>        {</td></tr><tr><th id="L81"><a href="#L81">81</a></th><td>            string s = Request.QueryString["s"];</td></tr><tr><th id="L82"><a href="#L82">82</a></th><td>            switch (s)</td></tr><tr><th id="L83"><a href="#L83">83</a></th><td>            {</td></tr><tr><th id="L84"><a href="#L84">84</a></th><td>                case "p":</td></tr><tr><th id="L85"><a href="#L85">85</a></th><td>                    selectServer(sType.production);</td></tr><tr><th id="L86"><a href="#L86">86</a></th><td>                    break;</td></tr><tr><th id="L87"><a href="#L87">87</a></th><td></td></tr><tr><th id="L88"><a href="#L88">88</a></th><td>                case "t":</td></tr><tr><th id="L89"><a href="#L89">89</a></th><td>                    selectServer(sType.testing);</td></tr><tr><th id="L90"><a href="#L90">90</a></th><td>                    break;</td></tr><tr><th id="L91"><a href="#L91">91</a></th><td></td></tr><tr><th id="L92"><a href="#L92">92</a></th><td>                case "d":</td></tr><tr><th id="L93"><a href="#L93">93</a></th><td>                    selectServer(sType.development);</td></tr><tr><th id="L94"><a href="#L94">94</a></th><td>                    break;</td></tr><tr><th id="L95"><a href="#L95">95</a></th><td></td></tr><tr><th id="L96"><a href="#L96">96</a></th><td>                default:</td></tr><tr><th id="L97"><a href="#L97">97</a></th><td>                    selectServer(sType.production);</td></tr><tr><th id="L98"><a href="#L98">98</a></th><td>                    break;</td></tr><tr><th id="L99"><a href="#L99">99</a></th><td>            }</td></tr><tr><th id="L100"><a href="#L100">100</a></th><td>        }</td></tr><tr><th id="L101"><a href="#L101">101</a></th><td>        catch (Exception ex1) {selectServer(sType.production); }</td></tr><tr><th id="L102"><a href="#L102">102</a></th><td>        #endregion</td></tr><tr><th id="L103"><a href="#L103">103</a></th><td></td></tr><tr><th id="L104"><a href="#L104">104</a></th><td>        #region KML or Text?</td></tr><tr><th id="L105"><a href="#L105">105</a></th><td>        //File Output type</td></tr><tr><th id="L106"><a href="#L106">106</a></th><td>        bool isKML = true;</td></tr><tr><th id="L107"><a href="#L107">107</a></th><td>        try { isKML = (Request.QueryString["k"]) == "n" ? false : true; }</td></tr><tr><th id="L108"><a href="#L108">108</a></th><td>        catch (Exception ex) { isKML = true; }</td></tr><tr><th id="L109"><a href="#L109">109</a></th><td>        #endregion</td></tr><tr><th id="L110"><a href="#L110">110</a></th><td></td></tr><tr><th id="L111"><a href="#L111">111</a></th><td>        #region Network Link KML?</td></tr><tr><th id="L112"><a href="#L112">112</a></th><td>        bool isNetworkLink = false;</td></tr><tr><th id="L113"><a href="#L113">113</a></th><td>        try { isNetworkLink = (Request.QueryString["nl"]) == "y" ? true : false; }</td></tr><tr><th id="L114"><a href="#L114">114</a></th><td>        catch (Exception ex) { isNetworkLink = false; }</td></tr><tr><th id="L115"><a href="#L115">115</a></th><td>        #endregion</td></tr><tr><th id="L116"><a href="#L116">116</a></th><td></td></tr><tr><th id="L117"><a href="#L117">117</a></th><td>        // Clean files in cache dir</td></tr><tr><th id="L118"><a href="#L118">118</a></th><td>        CleanupFiles();</td></tr><tr><th id="L119"><a href="#L119">119</a></th><td></td></tr><tr><th id="L120"><a href="#L120">120</a></th><td>        // Build networklink KML</td></tr><tr><th id="L121"><a href="#L121">121</a></th><td>        if (isNetworkLink)</td></tr><tr><th id="L122"><a href="#L122">122</a></th><td>        {</td></tr><tr><th id="L123"><a href="#L123">123</a></th><td>//            Response.Write(isNetworkLink);</td></tr><tr><th id="L124"><a href="#L124">124</a></th><td>            buildNetworkLinkKML();</td></tr><tr><th id="L125"><a href="#L125">125</a></th><td>        }</td></tr><tr><th id="L126"><a href="#L126">126</a></th><td>        else</td></tr><tr><th id="L127"><a href="#L127">127</a></th><td>        {</td></tr><tr><th id="L128"><a href="#L128">128</a></th><td>            //Determine Scale</td></tr><tr><th id="L129"><a href="#L129">129</a></th><td>            //double angle = AngularSeparation(west, east, south, north);</td></tr><tr><th id="L130"><a href="#L130">130</a></th><td>            double angle = AngularSeparation(lookatRange);</td></tr><tr><th id="L131"><a href="#L131">131</a></th><td>            // Reduce total angle by length of bar --&gt; to 26.15% of original</td></tr><tr><th id="L132"><a href="#L132">132</a></th><td>            double jpegsize = 368.0; //pixel size of scale image</td></tr><tr><th id="L133"><a href="#L133">133</a></th><td>            double fscaling = jpegsize / horizPixels;</td></tr><tr><th id="L134"><a href="#L134">134</a></th><td>            double unit_angle = angle * fscaling;</td></tr><tr><th id="L135"><a href="#L135">135</a></th><td></td></tr><tr><th id="L136"><a href="#L136">136</a></th><td>            // Generate the image with an angle</td></tr><tr><th id="L137"><a href="#L137">137</a></th><td>            scale = Scaling(unit_angle,angle);</td></tr><tr><th id="L138"><a href="#L138">138</a></th><td>        }</td></tr><tr><th id="L139"><a href="#L139">139</a></th><td></td></tr><tr><th id="L140"><a href="#L140">140</a></th><td>        //Output KML</td></tr><tr><th id="L141"><a href="#L141">141</a></th><td>        ResponseToOutput(buildKML(), isKML, "Angle.kml");</td></tr><tr><th id="L142"><a href="#L142">142</a></th><td>    }</td></tr><tr><th id="L143"><a href="#L143">143</a></th><td></td></tr><tr><th id="L144"><a href="#L144">144</a></th><td>    #region buildNetworkLinkKML</td></tr><tr><th id="L145"><a href="#L145">145</a></th><td>    public string buildNetworkLinkKML()</td></tr><tr><th id="L146"><a href="#L146">146</a></th><td>    {</td></tr><tr><th id="L147"><a href="#L147">147</a></th><td>        StringBuilder sb = new StringBuilder();</td></tr><tr><th id="L148"><a href="#L148">148</a></th><td>        // &lt;xml&gt;</td></tr><tr><th id="L149"><a href="#L149">149</a></th><td>        kml222 KMLFile = kml222.CreateDocument();</td></tr><tr><th id="L150"><a href="#L150">150</a></th><td>        // &lt;kml&gt;</td></tr><tr><th id="L151"><a href="#L151">151</a></th><td>        KmlType kml = KMLFile.kml2.Append();</td></tr><tr><th id="L152"><a href="#L152">152</a></th><td>        // &lt;NetworkLink&gt;</td></tr><tr><th id="L153"><a href="#L153">153</a></th><td>        NetworkLinkType NetworkLink = kml.NetworkLink.Append();</td></tr><tr><th id="L154"><a href="#L154">154</a></th><td>        //      &lt;name&gt;</td></tr><tr><th id="L155"><a href="#L155">155</a></th><td>        stringType name = NetworkLink.name.Append();</td></tr><tr><th id="L156"><a href="#L156">156</a></th><td>        name.Value = "Angular Size";</td></tr><tr><th id="L157"><a href="#L157">157</a></th><td>        //      &lt;description&gt;</td></tr><tr><th id="L158"><a href="#L158">158</a></th><td>        stringType description = NetworkLink.description.Append();</td></tr><tr><th id="L159"><a href="#L159">159</a></th><td>        description.Value = "Calculates the angular scale";</td></tr><tr><th id="L160"><a href="#L160">160</a></th><td>        //      &lt;Link&gt;</td></tr><tr><th id="L161"><a href="#L161">161</a></th><td>        LinkType Link = NetworkLink.Link2.Append();</td></tr><tr><th id="L162"><a href="#L162">162</a></th><td>        anyURIType href = Link.href.Append();</td></tr><tr><th id="L163"><a href="#L163">163</a></th><td>        href.Value = "http://gsky.stsci.edu/AngleinGSky?";</td></tr><tr><th id="L164"><a href="#L164">164</a></th><td></td></tr><tr><th id="L165"><a href="#L165">165</a></th><td>        viewRefreshModeEnumType LviewRefreshMode = Link.viewRefreshMode.Append();</td></tr><tr><th id="L166"><a href="#L166">166</a></th><td>        LviewRefreshMode.Value = "onStop";</td></tr><tr><th id="L167"><a href="#L167">167</a></th><td>        stringType LviewFormat = Link.viewFormat.Append();</td></tr><tr><th id="L168"><a href="#L168">168</a></th><td>        LviewFormat.Value = "BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]&amp;amp;CAMERA=[lookatLon],[lookatLat],[lookatRange],[lookatTilt],[lookatHeading]&amp;amp;VIEW=[horizFov],[vertFov],[horizPixels],[vertPixels],[terrainEnabled]";</td></tr><tr><th id="L169"><a href="#L169">169</a></th><td></td></tr><tr><th id="L170"><a href="#L170">170</a></th><td>        return KMLFile.SaveToString(true).Replace("utf-16", "utf-8").Replace("/kml/2.2\"", "/kml/2.2\" hint=\"target=sky\"");</td></tr><tr><th id="L171"><a href="#L171">171</a></th><td></td></tr><tr><th id="L172"><a href="#L172">172</a></th><td>        // STATIC NETWORK LINK</td></tr><tr><th id="L173"><a href="#L173">173</a></th><td>        //&lt;?xml version="1.0" encoding="UTF-8"?&gt;</td></tr><tr><th id="L174"><a href="#L174">174</a></th><td>        //&lt;kml xmlns="http://earth.google.com/kml/2.2" hint="target=sky"&gt;</td></tr><tr><th id="L175"><a href="#L175">175</a></th><td>        //&lt;NetworkLink&gt;</td></tr><tr><th id="L176"><a href="#L176">176</a></th><td>        //    &lt;name&gt;Angular Size&lt;/name&gt;</td></tr><tr><th id="L177"><a href="#L177">177</a></th><td>        //    &lt;Link&gt;</td></tr><tr><th id="L178"><a href="#L178">178</a></th><td>        //        &lt;href&gt;http://gsky.stsci.edu/AngleinGSky?&lt;/href&gt;</td></tr><tr><th id="L179"><a href="#L179">179</a></th><td>        //        &lt;viewRefreshMode&gt;onStop&lt;/viewRefreshMode&gt;</td></tr><tr><th id="L180"><a href="#L180">180</a></th><td>        //        &lt;viewFormat&gt;BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]&amp;amp;CAMERA=[lookatLon],[lookatLat],[lookatRange],[lookatTilt],[lookatHeading]&amp;amp;VIEW=[horizFov],[vertFov],[horizPixels],[vertPixels],[terrainEnabled]</td></tr><tr><th id="L181"><a href="#L181">181</a></th><td>        //        &lt;/viewFormat&gt;</td></tr><tr><th id="L182"><a href="#L182">182</a></th><td>        //    &lt;/Link&gt;</td></tr><tr><th id="L183"><a href="#L183">183</a></th><td>        //&lt;/NetworkLink&gt;</td></tr><tr><th id="L184"><a href="#L184">184</a></th><td>        //&lt;/kml&gt;</td></tr><tr><th id="L185"><a href="#L185">185</a></th><td>    }</td></tr><tr><th id="L186"><a href="#L186">186</a></th><td>    #endregion</td></tr><tr><th id="L187"><a href="#L187">187</a></th><td></td></tr><tr><th id="L188"><a href="#L188">188</a></th><td>    #region BuildKML</td></tr><tr><th id="L189"><a href="#L189">189</a></th><td>    public string buildKML()</td></tr><tr><th id="L190"><a href="#L190">190</a></th><td>    {</td></tr><tr><th id="L191"><a href="#L191">191</a></th><td>        StringBuilder sb = new StringBuilder();</td></tr><tr><th id="L192"><a href="#L192">192</a></th><td></td></tr><tr><th id="L193"><a href="#L193">193</a></th><td>        // &lt;xml&gt;</td></tr><tr><th id="L194"><a href="#L194">194</a></th><td>        kml222 KMLFile = kml222.CreateDocument();</td></tr><tr><th id="L195"><a href="#L195">195</a></th><td></td></tr><tr><th id="L196"><a href="#L196">196</a></th><td>        // &lt;kml&gt;</td></tr><tr><th id="L197"><a href="#L197">197</a></th><td>        KmlType kml = KMLFile.kml2.Append();</td></tr><tr><th id="L198"><a href="#L198">198</a></th><td></td></tr><tr><th id="L199"><a href="#L199">199</a></th><td>        // Placemark</td></tr><tr><th id="L200"><a href="#L200">200</a></th><td>        //PlacemarkType Placemark = kml.Placemark.Append();</td></tr><tr><th id="L201"><a href="#L201">201</a></th><td>        //stringType Pname = Placemark.name.Append();</td></tr><tr><th id="L202"><a href="#L202">202</a></th><td>        //Pname.Value = "Angular Extent";</td></tr><tr><th id="L203"><a href="#L203">203</a></th><td>        //SnippetType Snippet = Placemark.Snippet.Append();</td></tr><tr><th id="L204"><a href="#L204">204</a></th><td>        //Snippet.Value = Scaling(dRA, dDec);</td></tr><tr><th id="L205"><a href="#L205">205</a></th><td></td></tr><tr><th id="L206"><a href="#L206">206</a></th><td>        // Screen Overlay</td></tr><tr><th id="L207"><a href="#L207">207</a></th><td>        ScreenOverlayType ScreenOverlay = kml.ScreenOverlay.Append();</td></tr><tr><th id="L208"><a href="#L208">208</a></th><td>        //DrawOrder</td></tr><tr><th id="L209"><a href="#L209">209</a></th><td>        intType drawOrder = ScreenOverlay.drawOrder.Append();</td></tr><tr><th id="L210"><a href="#L210">210</a></th><td>        drawOrder.Value = 0;</td></tr><tr><th id="L211"><a href="#L211">211</a></th><td>        //name</td></tr><tr><th id="L212"><a href="#L212">212</a></th><td>        stringType SOname = ScreenOverlay.name.Append();</td></tr><tr><th id="L213"><a href="#L213">213</a></th><td>        SOname.Value = scale;</td></tr><tr><th id="L214"><a href="#L214">214</a></th><td></td></tr><tr><th id="L215"><a href="#L215">215</a></th><td>        //Snippet</td></tr><tr><th id="L216"><a href="#L216">216</a></th><td>        SnippetType SOSnippet = ScreenOverlay.Snippet.Append();</td></tr><tr><th id="L217"><a href="#L217">217</a></th><td>        SOSnippet.Value = "Approximate angular size\n";</td></tr><tr><th id="L218"><a href="#L218">218</a></th><td>        booleanType SOopen = ScreenOverlay.open.Append();</td></tr><tr><th id="L219"><a href="#L219">219</a></th><td>        SOopen.Value = true;</td></tr><tr><th id="L220"><a href="#L220">220</a></th><td></td></tr><tr><th id="L221"><a href="#L221">221</a></th><td>        //Icon</td></tr><tr><th id="L222"><a href="#L222">222</a></th><td>        string filename = DateTime.Now.Ticks + ".png";</td></tr><tr><th id="L223"><a href="#L223">223</a></th><td>        addTextToImage(scale, filename);</td></tr><tr><th id="L224"><a href="#L224">224</a></th><td>        LinkType SOIcon = ScreenOverlay.Icon.Append();</td></tr><tr><th id="L225"><a href="#L225">225</a></th><td>        anyURIType SOIhref = SOIcon.href.Append();</td></tr><tr><th id="L226"><a href="#L226">226</a></th><td>        SOIhref.Value = currentPath + filename;</td></tr><tr><th id="L227"><a href="#L227">227</a></th><td></td></tr><tr><th id="L228"><a href="#L228">228</a></th><td>        //overlayXY</td></tr><tr><th id="L229"><a href="#L229">229</a></th><td>        vec2Type overlayXY = ScreenOverlay.overlayXY.Append();</td></tr><tr><th id="L230"><a href="#L230">230</a></th><td>        overlayXY.x.Value = 0;</td></tr><tr><th id="L231"><a href="#L231">231</a></th><td>        overlayXY.y.Value = 1;</td></tr><tr><th id="L232"><a href="#L232">232</a></th><td>        overlayXY.xunits.Value = "fraction";</td></tr><tr><th id="L233"><a href="#L233">233</a></th><td>        overlayXY.yunits.Value = "fraction";</td></tr><tr><th id="L234"><a href="#L234">234</a></th><td>        //screenXY </td></tr><tr><th id="L235"><a href="#L235">235</a></th><td>        ScreenOverlay.screenXY.Append();</td></tr><tr><th id="L236"><a href="#L236">236</a></th><td>        vec2Type screenXY = ScreenOverlay.screenXY.Append();</td></tr><tr><th id="L237"><a href="#L237">237</a></th><td>        screenXY.x.Value = 0;</td></tr><tr><th id="L238"><a href="#L238">238</a></th><td>        screenXY.y.Value = 1;</td></tr><tr><th id="L239"><a href="#L239">239</a></th><td>        screenXY.xunits.Value = "fraction";</td></tr><tr><th id="L240"><a href="#L240">240</a></th><td>        screenXY.yunits.Value = "fraction";</td></tr><tr><th id="L241"><a href="#L241">241</a></th><td>        //rotation</td></tr><tr><th id="L242"><a href="#L242">242</a></th><td>        vec2Type rotationXY = ScreenOverlay.rotationXY.Append();</td></tr><tr><th id="L243"><a href="#L243">243</a></th><td>        rotationXY.x.Value = 0;</td></tr><tr><th id="L244"><a href="#L244">244</a></th><td>        rotationXY.y.Value = 0;</td></tr><tr><th id="L245"><a href="#L245">245</a></th><td>        rotationXY.xunits.Value = "fraction";</td></tr><tr><th id="L246"><a href="#L246">246</a></th><td>        rotationXY.yunits.Value = "fraction";</td></tr><tr><th id="L247"><a href="#L247">247</a></th><td>        //size</td></tr><tr><th id="L248"><a href="#L248">248</a></th><td>        vec2Type size = ScreenOverlay.size.Append();</td></tr><tr><th id="L249"><a href="#L249">249</a></th><td>        size.x.Value = 0;</td></tr><tr><th id="L250"><a href="#L250">250</a></th><td>        size.y.Value = 0;</td></tr><tr><th id="L251"><a href="#L251">251</a></th><td>        size.xunits.Value = "fraction";</td></tr><tr><th id="L252"><a href="#L252">252</a></th><td>        size.yunits.Value = "fraction";</td></tr><tr><th id="L253"><a href="#L253">253</a></th><td></td></tr><tr><th id="L254"><a href="#L254">254</a></th><td>        return KMLFile.SaveToString(true).Replace("utf-16", "utf-8").Replace("/kml/2.2\"", "/kml/2.2\" hint=\"target=sky\"");</td></tr><tr><th id="L255"><a href="#L255">255</a></th><td></td></tr><tr><th id="L256"><a href="#L256">256</a></th><td>    }</td></tr><tr><th id="L257"><a href="#L257">257</a></th><td>    #endregion</td></tr><tr><th id="L258"><a href="#L258">258</a></th><td></td></tr><tr><th id="L259"><a href="#L259">259</a></th><td>    #region Scaling</td></tr><tr><th id="L260"><a href="#L260">260</a></th><td>    public string Scaling(double sep, double width)</td></tr><tr><th id="L261"><a href="#L261">261</a></th><td>    {</td></tr><tr><th id="L262"><a href="#L262">262</a></th><td>        string units = Convert.ToChar(176).ToString();//degree</td></tr><tr><th id="L263"><a href="#L263">263</a></th><td>        string wunits = units;//degree</td></tr><tr><th id="L264"><a href="#L264">264</a></th><td>        string tilde = Convert.ToChar(126).ToString();//tilde</td></tr><tr><th id="L265"><a href="#L265">265</a></th><td>        string cross = Convert.ToChar(215).ToString();//cross </td></tr><tr><th id="L266"><a href="#L266">266</a></th><td>        double osep = sep;</td></tr><tr><th id="L267"><a href="#L267">267</a></th><td>        double owidth = width;</td></tr><tr><th id="L268"><a href="#L268">268</a></th><td></td></tr><tr><th id="L269"><a href="#L269">269</a></th><td>        // Convert to Degrees, Arcmin or Arcsec when appropriate</td></tr><tr><th id="L270"><a href="#L270">270</a></th><td>        if (sep &lt; 1.0)</td></tr><tr><th id="L271"><a href="#L271">271</a></th><td>        {</td></tr><tr><th id="L272"><a href="#L272">272</a></th><td>            osep = sep * 60.0;</td></tr><tr><th id="L273"><a href="#L273">273</a></th><td>            units = "\'";//arcmin</td></tr><tr><th id="L274"><a href="#L274">274</a></th><td>        }</td></tr><tr><th id="L275"><a href="#L275">275</a></th><td></td></tr><tr><th id="L276"><a href="#L276">276</a></th><td>        if (sep &lt; (1.0 / 60.0))</td></tr><tr><th id="L277"><a href="#L277">277</a></th><td>        {</td></tr><tr><th id="L278"><a href="#L278">278</a></th><td>            osep = sep * 3600.0;</td></tr><tr><th id="L279"><a href="#L279">279</a></th><td>            units = "\"";//arcmin</td></tr><tr><th id="L280"><a href="#L280">280</a></th><td>        }</td></tr><tr><th id="L281"><a href="#L281">281</a></th><td></td></tr><tr><th id="L282"><a href="#L282">282</a></th><td>        // Convert to Degrees, Arcmin or Arcsec when appropriate</td></tr><tr><th id="L283"><a href="#L283">283</a></th><td>        if (width &lt; 1.0)</td></tr><tr><th id="L284"><a href="#L284">284</a></th><td>        {</td></tr><tr><th id="L285"><a href="#L285">285</a></th><td>            owidth = width * 60.0;</td></tr><tr><th id="L286"><a href="#L286">286</a></th><td>            wunits = "\'";//arcmin</td></tr><tr><th id="L287"><a href="#L287">287</a></th><td>        }</td></tr><tr><th id="L288"><a href="#L288">288</a></th><td></td></tr><tr><th id="L289"><a href="#L289">289</a></th><td>        if (sep &lt; (1.0 / 60.0))</td></tr><tr><th id="L290"><a href="#L290">290</a></th><td>        {</td></tr><tr><th id="L291"><a href="#L291">291</a></th><td>            owidth = width * 3600.0;</td></tr><tr><th id="L292"><a href="#L292">292</a></th><td>            wunits = "\"";//arcmin</td></tr><tr><th id="L293"><a href="#L293">293</a></th><td>        }</td></tr><tr><th id="L294"><a href="#L294">294</a></th><td></td></tr><tr><th id="L295"><a href="#L295">295</a></th><td>        return String.Format(tilde + "{0:f2}" + units + "\n full width:" + tilde + "{1:f2}" + wunits, osep, owidth);</td></tr><tr><th id="L296"><a href="#L296">296</a></th><td>//        return String.Format(tilde + "{0:f2}" + units, osep, owidth);</td></tr><tr><th id="L297"><a href="#L297">297</a></th><td></td></tr><tr><th id="L298"><a href="#L298">298</a></th><td>    }</td></tr><tr><th id="L299"><a href="#L299">299</a></th><td>    #endregion</td></tr><tr><th id="L300"><a href="#L300">300</a></th><td></td></tr><tr><th id="L301"><a href="#L301">301</a></th><td>    #region addTextToImage</td></tr><tr><th id="L302"><a href="#L302">302</a></th><td>    public void addTextToImage(string text,string filename)</td></tr><tr><th id="L303"><a href="#L303">303</a></th><td>    {</td></tr><tr><th id="L304"><a href="#L304">304</a></th><td>        Bitmap bmp = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "scale.png");</td></tr><tr><th id="L305"><a href="#L305">305</a></th><td>        Graphics g = Graphics.FromImage(bmp);</td></tr><tr><th id="L306"><a href="#L306">306</a></th><td>        g.SmoothingMode = SmoothingMode.AntiAlias;</td></tr><tr><th id="L307"><a href="#L307">307</a></th><td>        //scale, aligned at the center</td></tr><tr><th id="L308"><a href="#L308">308</a></th><td>        StringFormat fmt = new StringFormat();</td></tr><tr><th id="L309"><a href="#L309">309</a></th><td>        fmt.Alignment = StringAlignment.Center;</td></tr><tr><th id="L310"><a href="#L310">310</a></th><td>        g.DrawString(text, new Font("Verdana", 10, System.Drawing.FontStyle.Bold), SystemBrushes.Info, 182, 19,fmt);</td></tr><tr><th id="L311"><a href="#L311">311</a></th><td>        //Bitmap newbmp = new Bitmap(bmp.Width, bmp.Height,bmp.PixelFormat); </td></tr><tr><th id="L312"><a href="#L312">312</a></th><td>        //Graphics Gnewbmp = Graphics.FromImage(newbmp);</td></tr><tr><th id="L313"><a href="#L313">313</a></th><td>        //Gnewbmp.DrawImage(bmp, new Point(1, 1));</td></tr><tr><th id="L314"><a href="#L314">314</a></th><td>        //Gnewbmp.Dispose();</td></tr><tr><th id="L315"><a href="#L315">315</a></th><td>        //bmp.Dispose();</td></tr><tr><th id="L316"><a href="#L316">316</a></th><td>        bmp.Save(AppDomain.CurrentDomain.BaseDirectory + "cache/" + filename, ImageFormat.Png);</td></tr><tr><th id="L317"><a href="#L317">317</a></th><td>        bmp.Dispose();</td></tr><tr><th id="L318"><a href="#L318">318</a></th><td>    }</td></tr><tr><th id="L319"><a href="#L319">319</a></th><td></td></tr><tr><th id="L320"><a href="#L320">320</a></th><td>    #endregion </td></tr><tr><th id="L321"><a href="#L321">321</a></th><td></td></tr><tr><th id="L322"><a href="#L322">322</a></th><td>    #region Cleanup tmp files older than 5 min</td></tr><tr><th id="L323"><a href="#L323">323</a></th><td>    public void CleanupFiles()</td></tr><tr><th id="L324"><a href="#L324">324</a></th><td>    {</td></tr><tr><th id="L325"><a href="#L325">325</a></th><td>        // NB I had to grant (in Explorer):</td></tr><tr><th id="L326"><a href="#L326">326</a></th><td>        // - write privileges to the anonymous user</td></tr><tr><th id="L327"><a href="#L327">327</a></th><td>        // - delete special privileges to the anonymous user</td></tr><tr><th id="L328"><a href="#L328">328</a></th><td></td></tr><tr><th id="L329"><a href="#L329">329</a></th><td>        // Detele Interval</td></tr><tr><th id="L330"><a href="#L330">330</a></th><td>        double dT = 5.0;</td></tr><tr><th id="L331"><a href="#L331">331</a></th><td></td></tr><tr><th id="L332"><a href="#L332">332</a></th><td>        // Set Dir</td></tr><tr><th id="L333"><a href="#L333">333</a></th><td>        DirectoryInfo dTmp = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "cache/");</td></tr><tr><th id="L334"><a href="#L334">334</a></th><td></td></tr><tr><th id="L335"><a href="#L335">335</a></th><td>        // Loop over files</td></tr><tr><th id="L336"><a href="#L336">336</a></th><td>        foreach (FileInfo file in dTmp.GetFiles("*.png"))</td></tr><tr><th id="L337"><a href="#L337">337</a></th><td>        {</td></tr><tr><th id="L338"><a href="#L338">338</a></th><td>            if (file.LastWriteTime &lt; DateTime.Now.AddMinutes(-dT))</td></tr><tr><th id="L339"><a href="#L339">339</a></th><td>            {</td></tr><tr><th id="L340"><a href="#L340">340</a></th><td>                file.Delete();</td></tr><tr><th id="L341"><a href="#L341">341</a></th><td>            }</td></tr><tr><th id="L342"><a href="#L342">342</a></th><td>        }</td></tr><tr><th id="L343"><a href="#L343">343</a></th><td>    }</td></tr><tr><th id="L344"><a href="#L344">344</a></th><td>    #endregion</td></tr><tr><th id="L345"><a href="#L345">345</a></th><td></td></tr><tr><th id="L346"><a href="#L346">346</a></th><td>    #region AngularSeparation</td></tr><tr><th id="L347"><a href="#L347">347</a></th><td>    public double AngularSeparation(double a1, double a2, double d1, double d2)</td></tr><tr><th id="L348"><a href="#L348">348</a></th><td>    {</td></tr><tr><th id="L349"><a href="#L349">349</a></th><td>        //Taken from 3rd formula in http://en.wikipedia.org/wiki/Great-circle_distance</td></tr><tr><th id="L350"><a href="#L350">350</a></th><td>        //Convert all to Radians</td></tr><tr><th id="L351"><a href="#L351">351</a></th><td>        double D2R = Math.PI / 180.0;</td></tr><tr><th id="L352"><a href="#L352">352</a></th><td>        //Set some variables in Radians</td></tr><tr><th id="L353"><a href="#L353">353</a></th><td>        double da = (a1 - a2) * D2R;</td></tr><tr><th id="L354"><a href="#L354">354</a></th><td>        double dd = (d1 - d2) * D2R;</td></tr><tr><th id="L355"><a href="#L355">355</a></th><td>        d1 = d1 * D2R;</td></tr><tr><th id="L356"><a href="#L356">356</a></th><td>        d2 = d2 * D2R;</td></tr><tr><th id="L357"><a href="#L357">357</a></th><td>        double separation = 0.0;</td></tr><tr><th id="L358"><a href="#L358">358</a></th><td>        // Denominator</td></tr><tr><th id="L359"><a href="#L359">359</a></th><td>        double denominator = Math.Sin(d1) * Math.Sin(d2) + Math.Cos(d1) * Math.Cos(d2) * Math.Cos(da);</td></tr><tr><th id="L360"><a href="#L360">360</a></th><td></td></tr><tr><th id="L361"><a href="#L361">361</a></th><td>        //Numerator</td></tr><tr><th id="L362"><a href="#L362">362</a></th><td>        double num1 = Math.Pow(Math.Cos(d2) * Math.Sin(da), 2.0);</td></tr><tr><th id="L363"><a href="#L363">363</a></th><td>        double num2 = Math.Pow(Math.Cos(d1) * Math.Sin(d2) - Math.Sin(d1) * Math.Cos(d2) * Math.Cos(da), 2.0);</td></tr><tr><th id="L364"><a href="#L364">364</a></th><td>        double numerator = Math.Sqrt(num1 + num2);</td></tr><tr><th id="L365"><a href="#L365">365</a></th><td></td></tr><tr><th id="L366"><a href="#L366">366</a></th><td>        separation = Math.Atan2(numerator, denominator);</td></tr><tr><th id="L367"><a href="#L367">367</a></th><td></td></tr><tr><th id="L368"><a href="#L368">368</a></th><td>        return separation / D2R;//in degrees</td></tr><tr><th id="L369"><a href="#L369">369</a></th><td></td></tr><tr><th id="L370"><a href="#L370">370</a></th><td>    }</td></tr><tr><th id="L371"><a href="#L371">371</a></th><td>    #endregion</td></tr><tr><th id="L372"><a href="#L372">372</a></th><td></td></tr><tr><th id="L373"><a href="#L373">373</a></th><td>    #region AngularSeparation (overload)</td></tr><tr><th id="L374"><a href="#L374">374</a></th><td>    public double AngularSeparation(double range)</td></tr><tr><th id="L375"><a href="#L375">375</a></th><td>    {</td></tr><tr><th id="L376"><a href="#L376">376</a></th><td>        double D2R = Math.PI / 180.0;</td></tr><tr><th id="L377"><a href="#L377">377</a></th><td>        double RoE = 6371.0 * 1000.0; //Earth Radius in meters</td></tr><tr><th id="L378"><a href="#L378">378</a></th><td>        double alpha = 80.0; //alpha is the angle subtended by the viewer when you are viewing from the maximum distance from the sky</td></tr><tr><th id="L379"><a href="#L379">379</a></th><td>        double separation = 2 * range * Math.Tan(D2R * alpha / 2.0) / RoE;</td></tr><tr><th id="L380"><a href="#L380">380</a></th><td></td></tr><tr><th id="L381"><a href="#L381">381</a></th><td>        return separation / D2R;//in degrees</td></tr><tr><th id="L382"><a href="#L382">382</a></th><td>    }</td></tr><tr><th id="L383"><a href="#L383">383</a></th><td>    #endregion</td></tr><tr><th id="L384"><a href="#L384">384</a></th><td>    </td></tr><tr><th id="L385"><a href="#L385">385</a></th><td>    #region ResponsetoOutput</td></tr><tr><th id="L386"><a href="#L386">386</a></th><td>    public void ResponseToOutput(string text, bool isKML, string KMLFilename)</td></tr><tr><th id="L387"><a href="#L387">387</a></th><td>    {</td></tr><tr><th id="L388"><a href="#L388">388</a></th><td>        Response.Clear();</td></tr><tr><th id="L389"><a href="#L389">389</a></th><td>        Response.ClearContent();</td></tr><tr><th id="L390"><a href="#L390">390</a></th><td></td></tr><tr><th id="L391"><a href="#L391">391</a></th><td>        if (isKML)</td></tr><tr><th id="L392"><a href="#L392">392</a></th><td>        {</td></tr><tr><th id="L393"><a href="#L393">393</a></th><td>            // Dump out special header and the file content and end the response</td></tr><tr><th id="L394"><a href="#L394">394</a></th><td>            Response.ContentType = "application/vnd.google-earth.kml+xml";</td></tr><tr><th id="L395"><a href="#L395">395</a></th><td>            //Response.ContentType = "application/xml";</td></tr><tr><th id="L396"><a href="#L396">396</a></th><td>            Response.AddHeader("Content-Disposition", "attachment; filename=" + KMLFilename);</td></tr><tr><th id="L397"><a href="#L397">397</a></th><td>        }</td></tr><tr><th id="L398"><a href="#L398">398</a></th><td>        else</td></tr><tr><th id="L399"><a href="#L399">399</a></th><td>        {</td></tr><tr><th id="L400"><a href="#L400">400</a></th><td>            Response.ContentType = "text/plain";</td></tr><tr><th id="L401"><a href="#L401">401</a></th><td>        }</td></tr><tr><th id="L402"><a href="#L402">402</a></th><td></td></tr><tr><th id="L403"><a href="#L403">403</a></th><td>        //This header (RFC 1806) lets us set the suggested filename</td></tr><tr><th id="L404"><a href="#L404">404</a></th><td>        Response.ContentEncoding = Encoding.UTF8;</td></tr><tr><th id="L405"><a href="#L405">405</a></th><td>        Response.Write(text);</td></tr><tr><th id="L406"><a href="#L406">406</a></th><td>        Response.End();</td></tr><tr><th id="L407"><a href="#L407">407</a></th><td>    }</td></tr><tr><th id="L408"><a href="#L408">408</a></th><td>    #endregion</td></tr><tr><th id="L409"><a href="#L409">409</a></th><td></td></tr><tr><th id="L410"><a href="#L410">410</a></th><td>    #region SelectServer</td></tr><tr><th id="L411"><a href="#L411">411</a></th><td>    public void selectServer(sType serverType)</td></tr><tr><th id="L412"><a href="#L412">412</a></th><td>    {</td></tr><tr><th id="L413"><a href="#L413">413</a></th><td>        switch (serverType)</td></tr><tr><th id="L414"><a href="#L414">414</a></th><td>        {</td></tr><tr><th id="L415"><a href="#L415">415</a></th><td>            case sType.production:</td></tr><tr><th id="L416"><a href="#L416">416</a></th><td>                currentServer = "http://gsky.stsci.edu/";</td></tr><tr><th id="L417"><a href="#L417">417</a></th><td>                currentPath = AppDomain.CurrentDomain.BaseDirectory.Replace(@"D:\googlesky\", currentServer).Replace("\\", "/") + "cache/";</td></tr><tr><th id="L418"><a href="#L418">418</a></th><td>                break;</td></tr><tr><th id="L419"><a href="#L419">419</a></th><td>            case sType.testing:</td></tr><tr><th id="L420"><a href="#L420">420</a></th><td>                currentServer = "http://vxp_ether.stsci.edu/";</td></tr><tr><th id="L421"><a href="#L421">421</a></th><td>                currentPath = AppDomain.CurrentDomain.BaseDirectory.Replace(@"C:\Sky\", currentServer).Replace("\\", "/") + "cache/";</td></tr><tr><th id="L422"><a href="#L422">422</a></th><td>                break;</td></tr><tr><th id="L423"><a href="#L423">423</a></th><td>            case sType.development:</td></tr><tr><th id="L424"><a href="#L424">424</a></th><td>                currentServer = "http://192.168.1.5/";</td></tr><tr><th id="L425"><a href="#L425">425</a></th><td>                currentPath = AppDomain.CurrentDomain.BaseDirectory.Replace(@"C:\Sky\", currentServer).Replace("\\", "/") + "cache/";</td></tr><tr><th id="L426"><a href="#L426">426</a></th><td>                break;</td></tr><tr><th id="L427"><a href="#L427">427</a></th><td>        }</td></tr><tr><th id="L428"><a href="#L428">428</a></th><td>    }</td></tr><tr><th id="L429"><a href="#L429">429</a></th><td>    #endregion</td></tr><tr><th id="L430"><a href="#L430">430</a></th><td>}</td></tr></tbody></table>

      </div>
      <div id="help"><strong>Note:</strong> See <a href="/trac/GoogleSky/wiki/TracBrowser">TracBrowser</a>
        for help on using the repository browser.</div>
      <div id="anydiff">
        <form action="/trac/GoogleSky/diff" method="get">
          <div class="buttons">
            <input type="hidden" name="new_path" value="/trunk/sky/AngleInGSky/Default.aspx.cs" />
            <input type="hidden" name="old_path" value="/trunk/sky/AngleInGSky/Default.aspx.cs" />
            <input type="hidden" name="new_rev" />
            <input type="hidden" name="old_rev" />
            <input type="submit" value="View changes..." title="Select paths and revs for Diff" />
          </div>
        </form>
      </div>
    </div>
    <div id="altlinks">
      <h3>Download in other formats:</h3>
      <ul>
        <li class="first">
          <a rel="nofollow" href="/trac/GoogleSky/browser/trunk/sky/AngleInGSky/Default.aspx.cs?format=txt">Plain Text</a>
        </li><li class="last">
          <a rel="nofollow" href="/trac/GoogleSky/export/303/trunk/sky/AngleInGSky/Default.aspx.cs">Original Format</a>
        </li>
      </ul>
    </div>
    </div>
    <div id="footer" lang="en" xml:lang="en"><hr />
      <a id="tracpowered" href="http://trac.edgewall.org/"><img src="/trac/GoogleSky/chrome/common/trac_logo_mini.png" height="30" width="107" alt="Trac Powered" /></a>
      <p class="left">Powered by <a href="/trac/GoogleSky/about"><strong>Trac 0.12</strong></a><br />
        By <a href="http://www.edgewall.org/">Edgewall Software</a>.</p>
      <p class="right">Visit the Trac open source project at<br /><a href="http://trac.edgewall.org/">http://trac.edgewall.org/</a></p>
    </div>
  </body>
</html>